package com.atguigu.rabbitmq.util;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;
// p17
/**
 * RabbitMq连接工具类
 */
public class RabbitMqUtils {

    //得到一个连续的channer
    public static Channel getChanner() throws IOException, TimeoutException {

        //创建一个连接工厂
        ConnectionFactory factory = new ConnectionFactory();
//        factory.setHost("192.168.232.128");
//        factory.setUsername("admin");
//        factory.setPassword("123");
        //工厂IP 连接RabbitMQ的队列
        factory.setHost("192.168.232.128");// 192.168.232.128
        //用户名
        factory.setUsername("admin");
        //密码
        factory.setPassword("123");// 123
        Connection connection = factory.newConnection();

        Channel channel = connection.createChannel();

        return channel;


    }
}